{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "from DistantSpeech.beamformer.utils import load_audio\n",
    "from scipy.signal import convolve as conv\n",
    "from matplotlib import pyplot as plt\n",
    "from tqdm import tqdm\n",
    "import numpy as np\n",
    "from DistantSpeech.adaptivefilter.BaseFilter import BaseFilter, awgn\n",
    "from DistantSpeech.adaptivefilter.FastFreqLms import FastFreqLms\n",
    "from DistantSpeech.beamformer.utils import load_audio as audioread\n",
    "from DistantSpeech.beamformer.utils import save_audio as audiowrite"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(336567,)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEICAYAAABS0fM3AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAA380lEQVR4nO3dd3wc1bXA8d/ZXfViVcuyXORubFywhbFpwfQaQwKBUPNCwssLpIeEhBSSF0hICCSkvECAhJJgAgngAAHc6G4yLrhbtmxLsprVe9m974+dHe3KK8lmZcvSnO/no49mZ2Z372hXc+bec+8dMcaglFLKuVwDXQCllFIDSwOBUko5nAYCpZRyOA0ESinlcBoIlFLK4TQQKKWUw2kgUANKRLaKyDkD8L73iMgzx/t9lToReQa6AMrZjDHTB7oMSjmd1giUOkZERC+01KCggUANKBHZJyLnW8v3iMjzIvKMiDSIyEciMllEviciFSJSJCIXBj33LRH5uYisFZF6EXlZRNKsbeeISHFP79Vtfaz1nlUiUisi60Qky9o2TEQeF5FSESkRkZ+JiLuHY7lHRF6wXqse+FxvzxeRiSLytojUicghEXku6LWMiHxVRPZa234lIi5rm0tEfiAi+62/y1MiMszalms99xYROWA99+6g150nIvnW36tcRB4M2j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3RjzYNCmIfn59nS8A/b5DnT2/Hj+4O9psAt/xv3ugS5PPx/bePy9CjYBWwPHB6QDy4HdwDIgbaDLGsExPou/utyBv4301p6OD39vkj9Yn/VHQN5Al7+fjvdp63g2WyeH7KD977aOdydwyUCX/yiP9Uz8zT6bgY3Wz6VD9fPt5XgH5PPVKSaUUsrhnNQ0pJRSKgwNBEop5XAaCJRSyuE0ECillMNpIFBKKYfTQKCUUg6ngUAppRzu/wH78G8VnU7YzQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# load source single and rir\n",
    "src = load_audio('/home/wangwei/work/DistantSpeech/samples/audio_samples/cleanspeech_aishell3.wav')\n",
    "src = np.random.rand(len(src))-0.5# * np.sqrt(npower)\n",
    "print(src.shape)\n",
    "rir = load_audio('/home/wangwei/work/DistantSpeech/DistantSpeech/adaptivefilter/rir.wav')\n",
    "rir = rir[200:]\n",
    "\n",
    "filter_len = 256\n",
    "\n",
    "rir = rir[:filter_len, np.newaxis]\n",
    "plt.figure()\n",
    "plt.plot(rir)\n",
    "plt.title('impulse response')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(336567,)\n",
      "(336567,)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 336311/336311 [00:00<00:00, 397339.94it/s]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA0YAAAHSCAYAAADITNtkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAVQklEQVR4nO3db4xld13H8c/XlhYVhJY2pWnB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Z/w/uvxtj/MO02Pm0QjYbI+fS6hpjfDnJ+5P8XI79tV3k+LGFmTG6aLpddYwxvpHkb/O9n0sLvd4Jo+19OMme6ZNHTsr6L+pdt+Rj+r5XVT9cVQ8/PJ/kGUluyfprf/hTSPYmefc0f12S502fZPLkJA9Mb52+J8kzquqU6XaHZyR5z7TuK1X15Ok+4efNPBfH5niMyVb74Cgd/odh8ktZP5+S9df2slr/pKZzk+zJ+i+xbnrtm37i9v4kl07fv3HMD4/TpUneN23PBtPf8Tck+cQY489nVjmfVsRWY+RcWi1VdXpVPXKa/8EkT8/674Md62u7yPFjxhZj9F8zwVJZ/92f2XNpede7sQKfWLHKU9Y/HeOTWb9n9cplH0+HKeuf/vLRabr18Oue9Xt6b0xyR5L3Jjl1Wl5JXjuN0ceTrM08169n/ZcoDyT5tZnla9NJeGeS12T6nx2bth2Xt2X91pFvZv0e3hccjzHZah+mYxqnN0/j8LHpH4ozZ7a/cnrNb8/MpzNude2bzs8PTeP3ziQnT8sfOj0+MK1/3LJfi1Wdkjwl67d0fCzJzdP0LOfT6kzbjJFzaYWmJD+V5D+n8bglycu+19d2UeNnOuoxet90Lt2S5C35zifXLfV6d/gbAQAA2nIrHQAA0J4wAgAA2hNGAABAe8IIAABoTxgBAADtCSMAAKA9YQQAALQnjAAAgPb+H0+YpslnwxvmAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 1008x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "\n",
    "data_clean = conv(src, rir[:, 0])\n",
    "data = data_clean[:len(src)]\n",
    "\n",
    "print(src.shape)\n",
    "print(data.shape)\n",
    "\n",
    "w = np.zeros((filter_len, 1))\n",
    "\n",
    "flms = FastFreqLms(filter_len=filter_len)\n",
    "flms.w[:] = rir\n",
    "\n",
    "valid_len = len(src)-flms.filter_len  # discard last frame\n",
    "\n",
    "\n",
    "est_err_flms = np.zeros(valid_len)\n",
    "\n",
    "output = np.zeros(data.shape)\n",
    "\n",
    "for n in tqdm(range((valid_len))):\n",
    "    if np.mod(n, flms.filter_len) == 0:\n",
    "        input_vector = src[n: n +  flms.filter_len]\n",
    "        d_vector = data[n : n + flms.filter_len]\n",
    "        err, w_flms = flms.update(input_vector, d_vector, update=False)\n",
    "\n",
    "        output[n : n + flms.filter_len] = err[:, 0]\n",
    "\n",
    "plt.figure(figsize=(14,8))\n",
    "plt.plot(data - output)\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "532cddd74b9fabc13f740f51c7600370dbbc74aaf96e64501f4b1ae280f38de4"
  },
  "kernelspec": {
   "display_name": "Python 3.8.8 ('.venv': venv)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
